package org.jetnuke.dao.sqlserver;

import org.apache.log4j.Logger;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

import net.jforum.JForumExecutionContext;
import net.jforum.util.preferences.SystemGlobals;

public class SqlServerRefererDAO extends
		org.jetnuke.dao.generic.GenericRefererDAO {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger
			.getLogger(SqlServerRefererDAO.class);

	public List selectOrderRID(int limit) throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug("selectOrderRID(int) - start"); //$NON-NLS-1$
		}

		String q1 = SystemGlobals.getSql("GenericModel.selectByLimit");
		String q2 = SystemGlobals.getSql("RefererModel.selectOrderRID");

		PreparedStatement p = JForumExecutionContext.getConnection()
				.prepareStatement(q1 + " " + limit + " " + q2);
		ResultSet rs = p.executeQuery();
		List list = this.processSelectAll(rs);
		rs.close();
		p.close();

		if (logger.isDebugEnabled()) {
			logger.debug("selectOrderRID(int) - end"); //$NON-NLS-1$
		}
		return list;
	}
}
